package com.itheima.myscoket.test8;

import java.io.*;
import java.net.Socket;

public class ClinetDmeo {
    public static void main(String[] args) throws IOException {
        //创建客户端Socket对象
        Socket socket = new Socket("127.0.0.1",10086);
        //创建字节缓冲流进行图片读取
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("day16_网络编程\\Client\\1.jpg"));
        //创建网络中的流
        OutputStream os = socket.getOutputStream();
        //jiang网络中的输出作为参数放入其中
        BufferedOutputStream bos = new BufferedOutputStream(os);
        //读取数据
        int len;
        while((len = bis.read())!=-1){
            bos.write(len);
        }
        //关闭输出
        socket.shutdownOutput();


        //客户端接收结果
        BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        String line;
        while((line = br.readLine() )!=null){
            System.out.println(line);
        }
        //关流
        br.close();
        socket.close();
    }
}
